#include <fstream>
#include <string>
#include <sstream>
#include "light_source.h"
/*#include "scene.h"
#include "material.h"
using namespace std;
float_type point_light_source::get_intensity(const intersection* i) const
{
	coord lvec = i->abs_pos-pos;
	return 1/coord::dot(lvec, lvec) *
		(myscene.point_screened(pos, i->abs_pos -pos, i->triangle)?
		0.5* intensity[i->wavelength]:intensity[i->wavelength]);
}
coord point_light_source::get_light_vec(const intersection* i) const
{
	return i->abs_pos-pos;
}
point_light_source::point_light_source(const RTscene& scene, const char filename[], const matrix4x4& trmat):
	light_source(scene), intensity(0)
{
	ifstream f(filename);
	string line, atom;
	while(!f.eof())
	{
		getline(f, line);
		stringstream ls(line);
		ls>>atom;
		if(atom == "pos"){
			ls>>pos.x>>pos.y>>pos.z;
			pos = trmat * pos;
		}
		else if (atom == "int")
		{
			float_type val;
			color_spectrum col;
			col.reserve(scene.wavelengths);
			while(!ls.eof())
			{
				ls>>val;
				if(!ls.fail())
					col.push_back(val);
			}
			material::resize_spectrum(col, scene.wavelengths, intensity);
		}
	}
}*/
